package com.ky.pro.java.sharding.ecommerce;

import com.ky.pro.java.sharding.ecommerce.entity.ComOrder;
import com.ky.pro.java.sharding.ecommerce.util.SnowflakeIdGenerator;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class OrderDataGenerator {

    public static List<ComOrder> genOrders(int orderCnt) {
        SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 0);
        SnowflakeIdGenerator oidGenerator = new SnowflakeIdGenerator(1, 1);
        SnowflakeIdGenerator uidGenerator = new SnowflakeIdGenerator(1, 2);

        List<ComOrder> orders = new ArrayList<>();
        for (int oi = 0; oi < orderCnt; oi++) {
            orders.add(ComOrder.builder()
                    .id(idGenerator.nextId())
                    .orderNo(String.valueOf(oidGenerator.nextId()))
                    .orderRemark("备注" + oi + "号")
                    .orderStatus(0)
                    .userId(uidGenerator.nextId())
                    .createTime(LocalDateTime.now())
                    .updateTime(LocalDateTime.now())
                    .delStatus(false)
                    .version(1)
                    .build());
        }

        return orders;
    }

}
